import 'package:domain/model/projects_domain_model.dart';
import 'package:ducafe_ui_core/ducafe_ui_core.dart';
import 'package:flutter/material.dart';

class ProjectItemView extends StatelessWidget {
  final Project project;
  final VoidCallback? onTapSameChapter;
  final VoidCallback? onTapItem;

  const ProjectItemView({
    super.key,
    required this.project,
    this.onTapItem,
    this.onTapSameChapter,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      child: _buildContent(),
    ).paddingDirectional(horizontal: 16.w);
  }

  Widget _buildContent() =>
      <Widget>[
            Text(
              project.title,
              style: TextStyle(color: Colors.black, fontSize: 16.sp),
            ),
            SizedBox(height: 4.h),
            Text(
              project.desc.trim(),
              style: TextStyle(color: Colors.black, fontSize: 13.sp),
            ),
            SizedBox(height: 8.h),
            <Widget>[
              Text(
                project.niceDate,
                style: TextStyle(color: Colors.grey, fontSize: 12.sp),
              ),
              SizedBox(width: 8.h),
              Text(
                '查看同类项目',
                style: TextStyle(color: Colors.grey, fontSize: 12.sp),
              ).onTap(onTapSameChapter, behavior: HitTestBehavior.opaque),
            ].toRow(crossAxisAlignment: CrossAxisAlignment.center),
          ]
          .toColumn(crossAxisAlignment: CrossAxisAlignment.start)
          .inkWell(onTap: onTapItem)
          .paddingDirectional(horizontal: 12.w, vertical: 8.h);
}
